package com.projectsexception.festivales.setup.xml;

import java.util.ArrayList;
import java.util.List;

import com.projectsexception.festivales.setup.FeedInfo;

import android.content.res.XmlResourceParser;

public class XMLHandlerFeedInfo extends AbstractXMLHandler<FeedInfo> {
    
    private List<FeedInfo> feeds;
    private FeedInfo tmpFeedInfo;

    @Override
    public void startDocument() {
        feeds = new ArrayList<FeedInfo>();
    }

    @Override
    public void startTag(XmlResourceParser res) {
        String s = res.getName();
        if (s.equals("feed")) {
            tmpFeedInfo = new FeedInfo();
            tmpFeedInfo.setName(res.getAttributeValue(null, "name"));
            tmpFeedInfo.setLink(res.getAttributeValue(null, "link"));
        }
    }

    @Override
    public void endTag(XmlResourceParser res) {
        if ("feed".equals(res.getName())) {
            feeds.add(tmpFeedInfo);
        }
    }

    @Override
    public List<FeedInfo> getResult() {
        return feeds;
    }

}
